using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace etbTOEIC
{
	/// <summary>
	/// Summary description for frmChangePassword.
	/// </summary>
	public class FormChangePassword : System.Windows.Forms.Form
	{
		private Lybra.Forms.Controls.GradientPanelXP gradientPanelXP1;
		private Lybra.Forms.Controls.HoverGradientButton hoverGradientButtonCancel;
		private Lybra.Forms.Controls.HoverGradientButton hoverGradientButtonChange;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox textBoxUser;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.TextBox textBoxPassConfirm;
		private System.Windows.Forms.TextBox textBoxPassNew;
		private System.Windows.Forms.TextBox textBoxPassOld;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public FormChangePassword()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FormChangePassword));
			this.gradientPanelXP1 = new Lybra.Forms.Controls.GradientPanelXP();
			this.textBoxPassConfirm = new System.Windows.Forms.TextBox();
			this.label3 = new System.Windows.Forms.Label();
			this.textBoxPassNew = new System.Windows.Forms.TextBox();
			this.label4 = new System.Windows.Forms.Label();
			this.hoverGradientButtonCancel = new Lybra.Forms.Controls.HoverGradientButton();
			this.hoverGradientButtonChange = new Lybra.Forms.Controls.HoverGradientButton();
			this.textBoxPassOld = new System.Windows.Forms.TextBox();
			this.label2 = new System.Windows.Forms.Label();
			this.textBoxUser = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.gradientPanelXP1.SuspendLayout();
			this.SuspendLayout();
			// 
			// gradientPanelXP1
			// 
			this.gradientPanelXP1.BackColor1 = System.Drawing.Color.WhiteSmoke;
			this.gradientPanelXP1.BackColor2 = System.Drawing.Color.Gray;
			this.gradientPanelXP1.Controls.Add(this.textBoxPassConfirm);
			this.gradientPanelXP1.Controls.Add(this.label3);
			this.gradientPanelXP1.Controls.Add(this.textBoxPassNew);
			this.gradientPanelXP1.Controls.Add(this.label4);
			this.gradientPanelXP1.Controls.Add(this.hoverGradientButtonCancel);
			this.gradientPanelXP1.Controls.Add(this.hoverGradientButtonChange);
			this.gradientPanelXP1.Controls.Add(this.textBoxPassOld);
			this.gradientPanelXP1.Controls.Add(this.label2);
			this.gradientPanelXP1.Controls.Add(this.textBoxUser);
			this.gradientPanelXP1.Controls.Add(this.label1);
			this.gradientPanelXP1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.gradientPanelXP1.Font = new System.Drawing.Font("Arial", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.gradientPanelXP1.Gradient = System.Drawing.Drawing2D.LinearGradientMode.Vertical;
			this.gradientPanelXP1.Location = new System.Drawing.Point(0, 0);
			this.gradientPanelXP1.Name = "gradientPanelXP1";
			this.gradientPanelXP1.Size = new System.Drawing.Size(384, 202);
			this.gradientPanelXP1.TabIndex = 1;
			// 
			// textBoxPassConfirm
			// 
			this.textBoxPassConfirm.Font = new System.Drawing.Font("Arial", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.textBoxPassConfirm.ForeColor = System.Drawing.Color.Blue;
			this.textBoxPassConfirm.Location = new System.Drawing.Point(150, 112);
			this.textBoxPassConfirm.Name = "textBoxPassConfirm";
			this.textBoxPassConfirm.PasswordChar = '*';
			this.textBoxPassConfirm.Size = new System.Drawing.Size(224, 25);
			this.textBoxPassConfirm.TabIndex = 3;
			this.textBoxPassConfirm.Text = "";
			// 
			// label3
			// 
			this.label3.BackColor = System.Drawing.Color.Transparent;
			this.label3.Font = new System.Drawing.Font("Arial", 11F);
			this.label3.ForeColor = System.Drawing.Color.Blue;
			this.label3.Location = new System.Drawing.Point(11, 112);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(137, 24);
			this.label3.TabIndex = 9;
			this.label3.Text = "Confirm Password :";
			this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// textBoxPassNew
			// 
			this.textBoxPassNew.Font = new System.Drawing.Font("Arial", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.textBoxPassNew.ForeColor = System.Drawing.Color.Blue;
			this.textBoxPassNew.Location = new System.Drawing.Point(150, 80);
			this.textBoxPassNew.Name = "textBoxPassNew";
			this.textBoxPassNew.PasswordChar = '*';
			this.textBoxPassNew.Size = new System.Drawing.Size(224, 25);
			this.textBoxPassNew.TabIndex = 2;
			this.textBoxPassNew.Text = "";
			// 
			// label4
			// 
			this.label4.BackColor = System.Drawing.Color.Transparent;
			this.label4.Font = new System.Drawing.Font("Arial", 11F);
			this.label4.ForeColor = System.Drawing.Color.Blue;
			this.label4.Location = new System.Drawing.Point(11, 80);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(139, 24);
			this.label4.TabIndex = 7;
			this.label4.Text = "New Password :";
			this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// hoverGradientButtonCancel
			// 
			this.hoverGradientButtonCancel.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)));
			this.hoverGradientButtonCancel.BackColor2 = System.Drawing.Color.RoyalBlue;
			this.hoverGradientButtonCancel.BorderHover = true;
			this.hoverGradientButtonCancel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.hoverGradientButtonCancel.Font = new System.Drawing.Font("Arial", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.hoverGradientButtonCancel.Location = new System.Drawing.Point(199, 161);
			this.hoverGradientButtonCancel.Name = "hoverGradientButtonCancel";
			this.hoverGradientButtonCancel.Size = new System.Drawing.Size(106, 31);
			this.hoverGradientButtonCancel.TabIndex = 5;
			this.hoverGradientButtonCancel.Text = "Cancel";
			this.hoverGradientButtonCancel.Click += new System.EventHandler(this.hoverGradientButtonCancel_Click);
			// 
			// hoverGradientButtonChange
			// 
			this.hoverGradientButtonChange.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)));
			this.hoverGradientButtonChange.BackColor2 = System.Drawing.Color.RoyalBlue;
			this.hoverGradientButtonChange.BorderHover = true;
			this.hoverGradientButtonChange.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.hoverGradientButtonChange.Font = new System.Drawing.Font("Arial", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.hoverGradientButtonChange.Location = new System.Drawing.Point(71, 161);
			this.hoverGradientButtonChange.Name = "hoverGradientButtonChange";
			this.hoverGradientButtonChange.Size = new System.Drawing.Size(106, 31);
			this.hoverGradientButtonChange.TabIndex = 4;
			this.hoverGradientButtonChange.Text = "Change";
			this.hoverGradientButtonChange.Click += new System.EventHandler(this.hoverGradientButtonChange_Click);
			// 
			// textBoxPassOld
			// 
			this.textBoxPassOld.Font = new System.Drawing.Font("Arial", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.textBoxPassOld.ForeColor = System.Drawing.Color.Blue;
			this.textBoxPassOld.Location = new System.Drawing.Point(151, 48);
			this.textBoxPassOld.Name = "textBoxPassOld";
			this.textBoxPassOld.PasswordChar = '*';
			this.textBoxPassOld.Size = new System.Drawing.Size(224, 25);
			this.textBoxPassOld.TabIndex = 1;
			this.textBoxPassOld.Text = "";
			// 
			// label2
			// 
			this.label2.BackColor = System.Drawing.Color.Transparent;
			this.label2.Font = new System.Drawing.Font("Arial", 11F);
			this.label2.ForeColor = System.Drawing.Color.Blue;
			this.label2.Location = new System.Drawing.Point(11, 48);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(135, 24);
			this.label2.TabIndex = 2;
			this.label2.Text = "Current Password :";
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// textBoxUser
			// 
			this.textBoxUser.Font = new System.Drawing.Font("Arial", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.textBoxUser.ForeColor = System.Drawing.Color.Blue;
			this.textBoxUser.Location = new System.Drawing.Point(151, 16);
			this.textBoxUser.Name = "textBoxUser";
			this.textBoxUser.Size = new System.Drawing.Size(224, 25);
			this.textBoxUser.TabIndex = 0;
			this.textBoxUser.Text = "";
			// 
			// label1
			// 
			this.label1.BackColor = System.Drawing.Color.Transparent;
			this.label1.Font = new System.Drawing.Font("Arial", 11F);
			this.label1.ForeColor = System.Drawing.Color.Blue;
			this.label1.Location = new System.Drawing.Point(11, 16);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(138, 24);
			this.label1.TabIndex = 0;
			this.label1.Text = "User Name :";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// FormChangePassword
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(8, 19);
			this.ClientSize = new System.Drawing.Size(384, 202);
			this.Controls.Add(this.gradientPanelXP1);
			this.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "FormChangePassword";
			this.ShowInTaskbar = false;
			this.Text = "Change Password";
			this.Load += new System.EventHandler(this.FormChangePassword_Load);
			this.gradientPanelXP1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void hoverGradientButtonChange_Click(object sender, System.EventArgs e)
		{
			string stUser = textBoxUser.Text.Trim();
			string stPassOld = textBoxPassOld.Text.Trim();
			string stPassNew = textBoxPassNew.Text.Trim();
			string stPassConfirm = textBoxPassConfirm.Text.Trim();
			if(stPassConfirm != stPassNew)
			{
				MessageBox.Show("Incorrect PassWord","Change Password");
				return;
			}
			if(MyDatabase.UpdatePass(stUser, stPassNew))
			{
				MessageBox.Show("Password Updated","Change Password");
			}else
			{
				MessageBox.Show("Incorrect PassWord","Change Password");
				return;
			}
		}

		private void hoverGradientButtonCancel_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void FormChangePassword_Load(object sender, System.EventArgs e)
		{
			textBoxUser.Text = DB2MainForm.stCurrentUser;
		}
	}
}
